<title>系统管理-编辑管理员</title>
<!-- /section:settings.box -->
<div class="row">
	<div class="col-xs-12 admin_editor">
		<form class="form-horizontal registerform">
			<div class="space-4"></div>
			<div class="space-4"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">用户名：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
					<?php
					if ($model ['id'] > 0) {
						echo $model ['account'];
					} else {
						?><input type="text" class="input-xlarge" datatype="*"
							id="hx_account" nullmsg="请输入用户名" placeholder="请输入用户名"
							title="限制数字字母和中文组成"><?php
					}
					?>						
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<?php
			if ($model ['id'] > 0) {
			} else {
				?>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">设置密码：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="password" class="input-xlarge" datatype="*"
							id="hx_pwd" nullmsg="请输入密码" placeholder="请输入密码">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">确认密码：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="password" class="input-xlarge" datatype="*"
							id="hx_check_pwd" nullmsg="请再次输入密码" placeholder="请再次输入密码">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<?php
			}
			?>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">姓名：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="text" class="input-xlarge" datatype="*" id="hx_name"
							nullmsg="请输入姓名" placeholder="请输入姓名" value="<?=$model['name']?>">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right"
					for="form-field-name">联系电话：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<input type="text" class="input-xlarge" datatype="*" id="hx_phone"
							value="<?=$model['phone']?>" nullmsg="请输入联系电话"
							placeholder="请输入联系电话">
					</div>
					<div class="tishi">
						<div class="Validform_checktip"></div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="form-field-name"
					class="col-sm-3 control-label no-padding-right">部门：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<select nullmsg="请选择所在部门" datatype="*" id="hx_depart">
							<option>请选择</option>
							<?php
							if (is_array ( $depList ) && count ( $depList ) > 0) {
								foreach ( $depList as $item ) {
									?>
									<option value="<?=$item['id']?>"><?=$item['depart_name']?></option>
									<?php
								}
							}
							?>
						</select>
					</div>
					<div class="tishi">
						<div class="Validform_checktip Validform_right">通过信息验证！</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label for="form-field-name"
					class="col-sm-3 control-label no-padding-right">职位：</label>
				<div class="input-group col-sm-9">
					<div class="in_txt">
						<select nullmsg="请选择职位" datatype="*" id="hx_pos">
							<option>请选择</option>
								<?php
								if (is_array ( $posList ) && count ( $posList ) > 0) {
									foreach ( $posList as $item ) {
										?>
									<option value="<?=$item['id']?>"><?=$item['sys_value']?></option>
									<?php
									}
								}
								?>
						</select>
					</div>
					<div class="tishi">
						<div class="Validform_checktip Validform_right">通过信息验证！</div>
					</div>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn btn-info save" type="button" id="btnSubmit">
						<i class="ace-icon fa fa-check bigger-110"></i>保存
					</button>
					&nbsp; &nbsp;
					<button class="btn" type="button">
						<i class="ace-icon glyphicon glyphicon-remove bigger-110"></i>取消
					</button>
				</div>
			</div>
			<input type="hidden" id="hx_id" value="<?=$model['id']?>" />
		</form>
	</div>
</div>
<script type="text/javascript">
var scripts = [null,null];
$('.page-content-area').ace_ajax('loadScripts', scripts, function(){
	var $scope = $(".admin_editor");
	//表单验证
	var vform=$(".registerform").Validform({
		tiptype:2
	});
	$("#hx_depart",$scope).val('<?=$model['depart_id']?>');
	$("#hx_pos",$scope).val('<?=$model['position_id']?>');
	$("#btnSubmit",$scope).click(function(){
		if(!vform.check(false))
		{
			return;	
		}	
	 var id = $("#hx_id",$scope).val(); 
	 var account = $("#hx_account",$scope).val();
	 var name=$("#hx_name",$scope).val();
	 var pwd = $("#hx_pwd",$scope).val();
	 var phone = $("#hx_phone",$scope).val();
	 var depart = $("#hx_depart",$scope).val();
	 var pos = $("#hx_pos",$scope).val();
	 $.post('/sys/ajax_admin_editor',{
		 	'id':id,
		 	'account':account,
			'name':name,
			'pwd':pwd,
			'phone':phone,
			'depart':depart,
			'pos':pos
		},function(data){
			if(200===data.status)
			{
				message_box.show(data.data);
				gDialog.fClose();
				if ( typeof(pageObj) != "undefined" ) {		
					if(data.page<pageObj.get_page_count()){
						pageObj.dec_page_count();//-1
						if(pageObj.get_page_index() > pageObj.get_page_count()){
							pageObj.go_page(pageObj.get_page_count());
						}else{
							pageObj.cur_page();
						}
					  }else{
						pageObj.cur_page();
					  }		
				 }		
			}else
			{
			  message_box.show(data.data);
			}
			 
	},'json');
	});
})
</script>
